import json

from django.http import JsonResponse
from django.shortcuts import render

# Create your views here.
def login(request):
    json_data=request.body.decode()
    data=json.loads(json_data)
    name = data.get("name")
    pwd = data.get("pwd")
    print(name,pwd)
    if not all([name,pwd]):
        resp = {
            "code": 400,
            "msg": "参数不全",
            "data": {
            }
        }
        return JsonResponse(resp)
    if name=="zhangsan" and pwd =="1234":
        resp={
            "code":200,
            "msg":"登录成功",
            "data":{
                "name":"张三",
                "id":1,
            }
        }
        return JsonResponse(resp)